package com.frame.common.tools.exceptions;

import com.frame.common.tools.result.ResultCode;

/**
 * Created in com.sdebank.arcsync.common.
 * description
 *
 * @author xieran
 * @date 2019/09/17 16:53
 */
public class ServiceException extends Exception {

    private static final long serialVersionUID = 1L;

    /**
     * 错误码
     */
    private String errCode;

    /**
     * 错误描述
     */
    private String errMsg;

    public ServiceException() {
        super();
    }

    public ServiceException(ResultCode resultCode) {
        super(resultCode.getContent());
        this.setErrCode(resultCode.getCode());
        this.setErrMsg(resultCode.getContent());
    }

    public ServiceException(String errCode, String errMsg) {
        super(errMsg);
        this.setErrCode(errCode);
        this.setErrMsg(errMsg);
    }

    public ServiceException(String errMsg) {
        super(errMsg);
        this.setErrCode(ResultCode.ERROR.getCode());
        this.setErrMsg(errMsg);
    }

    public ServiceException(String errMsg, Throwable cause) {
        super(errMsg, cause);
        this.setErrCode(ResultCode.ERROR.getCode());
        this.setErrMsg(errMsg);
    }

    public ServiceException(String errCode, String errMsg, Throwable cause) {
        super(errMsg, cause);
        this.setErrCode(errCode);
        this.setErrMsg(errMsg);
    }

    public String getErrCode() {
        return errCode;
    }

    public void setErrCode(String errCode) {
        this.errCode = errCode;
    }

    public String getErrMsg() {
        return errMsg;
    }

    public void setErrMsg(String errMsg) {
        this.errMsg = errMsg;
    }
}
